package cn.tianjindong.blog_portal.controller;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSON;

import cn.tianjindong.blog.common.utils.VisiterInfoUtils;

/**
 * 该类用于处理访问者信息
 * @author 田 金 东
 *
 */
@Controller
public class VisiterController {
	
	@RequestMapping("/visit-info.action")
	public @ResponseBody String visitInfo(HttpServletRequest request){
		String ip = VisiterInfoUtils.getIpAddress(request);
		String system = VisiterInfoUtils.getSystem(request);
		String browser = VisiterInfoUtils.getBrowser(request);
		Map<String, String> map = new HashMap<>();
		map.put("ip", ip);
		map.put("system", system);
		map.put("browser", browser);
		return JSON.toJSONString(map);
	}
}
